﻿using MediatR;
using SheepStorage.API.Application.Command.SheepFieldCommand;
using SheepStorage.API.Application.Command.SheepManagementCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepFieldCommandHandler
{
    public class SheepFieldListHandler : IRequestHandler<SheepFieldListCommand, Results<List<SheepField>>>
    {
        private readonly ISheepFieldService sheepFieldService;

        public SheepFieldListHandler(ISheepFieldService sheepFieldService)
        {
            this.sheepFieldService = sheepFieldService;
        }

        /// <summary>
        /// 栏位显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<List<SheepField>>> Handle(SheepFieldListCommand request, CancellationToken cancellationToken)
        {
            return Results<List<SheepField>>.DataResult(await sheepFieldService.GetSheepField(request.BuildingManagementId));
        }
    }
}
